#include <Arduino.h>
#include "TFT_eSPI.h"
#include "pin_config.h"
#include "drv_tft.h"

#define TFT_ROTATION  1

TFT_eSPI tft =  TFT_eSPI();

static bool s_tft_initialized = false;

bool drv_tft_init(void) {

  if (s_tft_initialized) {
    return true;
  }

  tft.init();
  tft.setRotation(TFT_ROTATION);
  tft.fillScreen(TFT_BLACK);
  pinMode(TFT_LEDA_PIN, OUTPUT);
  digitalWrite(TFT_LEDA_PIN, LOW);

  tft.setTextFont(1);
  tft.setTextColor(TFT_GREEN, TFT_BLACK);
  tft.println("system init");

  s_tft_initialized = true;
  return true;
}